#-*- coding:utf-8 -*-
"""jndream URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from django.conf.urls.static import static
from django.conf import settings
from forums.views import register,login
from django.contrib.auth.views import logout
from rest_framework import routers, serializers, viewsets
from django.contrib.auth.models import User
import notifications

router = routers.DefaultRouter()

#定义程序的的输出形式
class UserSerializer(serializers.HyperlinkedModelSerializer):
    class Meta:
        model = User
        fields = ('url', 'username', 'email', 'is_staff')

#定义views当中函数的行为
class UserViewSet(viewsets.ModelViewSet):
    queryset = User.objects.all()
    serializer_class = UserSerializer

#自动生成url conf
router.register(r'users', UserViewSet)

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'',include('forums.urls')),
    url(r'^bpi/',include(router.urls)),
    url(r'^account/register/$',register,name='register'),
    url(r'^accounts/login/$', login,name='login'),
    url(r'^accounts/logout/$',logout,{'next_page':'/'}),
    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    # url(r'^tinymce/', include('tinymce.urls')),
    url(r'^ueditor/',include('DjangoUeditor.urls' )),
    url('^inbox/notifications/', include(notifications.urls)),

]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
